<?php
html::printPath(
    array('myRegistration.form-title' => '/user/myRegistration/all', 'myRegistration.displayPage-title' => ''),
    'myRegistration.displayPage-desc'
);
$msg->printMessages();

echo '<ul class="commandList" style="margin-top: 0.5em">';
if (registrationUtils::canBeCancelled($registration, $registration['seminar'], $registration['payment_acceptance'])) {
    echo '<li class="deleteLi"><a href="#" onclick="return openInDialog(\'cancellationDialog\', \'' . text::getEscaped('myRegistration.cancellation') . '\');">' . text::getEscaped('myRegistration.cancellation') . '</a></li>';
}
else if (date::isInPast($seminar['begin_date'], $seminar['begin_time'])) {
	// FIXME: closed accounting can be the reason too
    if (date::isInPast($seminar['end_date'], $seminar['end_time'])) {
        echo text::getEscaped('myRegistration.cannotBeCancelled-seminarFinished');
    }
    else {
        echo text::getEscaped('myRegistration.cannotBeCancelled-seminarRunning');
    }
}
echo '</ul>';

// Cancellation dialog
echo '<div id="cancellationDialog" class="hidden">';

// If the registration is already paid, the money will be returned.
// echo '<p>' . text::getEscaped('myRegistration.returnMoneyIfCancelled') . '</p>';
// If the registration is not paid yet, just cancel it.
if (! $registration['paid_price']) {
	echo '<p>' . text::getEscaped('myRegistration.regIsNotPaidYet') . '</p>';
}

$fb = new FormBuilder('registration', $registration);
$fb->setAction('/user/myRegistration/cancelRegistration');
$fb->textarea('cancellation_reason');
$fb->submitButton('myRegistration.cancelThis');
$fb->write();

echo '</div>';

registrationHelper::printWholeRegistration($registration);
